Add gtk_icon_paintable_get_resource_path()
authorAlexander Larsson <alexl@redhat.com>
Thu, 6 Feb 2020 16:33:19 +0000 (17:33 +0100)
committerAlexander Larsson <alexl@redhat.com>
Thu, 6 Feb 2020 16:47:57 +0000 (17:47 +0100)
Also, return NULL from gtk_icon_paintable_get_filename() if the path
is really a resource path.

docs/reference/gtk/gtk4-sections.txt
gtk/gtkicontheme.c
gtk/gtkicontheme.h

index 3316829a805eba50398d6e1a326d8eda78a7bc04..aa7726bb5379ce7225dafb4419df1125380a10fa 100644 (file)
@@ -5010,6 +5010,7 @@ gtk_icon_theme_lookup_by_gicon
 gtk_icon_theme_list_icons
 gtk_icon_theme_get_icon_sizes
 gtk_icon_paintable_get_filename
+gtk_icon_paintable_get_resource_path
 gtk_icon_paintable_get_icon_name
 gtk_icon_paintable_is_symbolic
 <SUBSECTION Standard>
index 65459be8e31bdebcad51b6a878af3cd38daa4c53..5c4ce8160c97070c819f37bf1969a23c5183c691 100644 (file)
@@ -3130,7 +3130,28 @@ gtk_icon_paintable_get_filename (GtkIconPaintable *icon)
 {
   g_return_val_if_fail (icon != NULL, NULL);
 
-  return icon->filename;
+  if (!icon->is_resource)
+    return icon->filename;
+  return NULL;
+}
+
+/**
+ * gtk_icon_paintable_get_resource_path:
+ * @self: a #GtkIcon
+ *
+ * Gets the resource path for the icon.
+ *
+ * Returns: (nullable) (type filename): the resource for the icon, or %NULL
+ *     if the icon is not represented by a resource.
+ */
+const gchar *
+gtk_icon_paintable_get_resource_path (GtkIconPaintable *icon)
+{
+  g_return_val_if_fail (icon != NULL, NULL);
+
+  if (icon->is_resource)
+    return icon->filename;
+  return NULL;
 }
 
 /**
index 2a3366b7d5759d6a8713c066843270c22cc5d634..afc79e5a1860d43dcf5ed8d1f82dc396ff2fc9b9 100644 (file)
@@ -137,11 +137,13 @@ GDK_AVAILABLE_IN_ALL
 GType                 gtk_icon_paintable_get_type         (void) G_GNUC_CONST;
 
 GDK_AVAILABLE_IN_ALL
-const gchar *         gtk_icon_paintable_get_filename     (GtkIconPaintable  *self);
+const gchar *         gtk_icon_paintable_get_filename      (GtkIconPaintable  *self);
 GDK_AVAILABLE_IN_ALL
-const gchar *         gtk_icon_paintable_get_icon_name    (GtkIconPaintable  *self);
+const gchar *         gtk_icon_paintable_get_resource_path (GtkIconPaintable  *self);
 GDK_AVAILABLE_IN_ALL
-gboolean              gtk_icon_paintable_is_symbolic      (GtkIconPaintable  *self);
+const gchar *         gtk_icon_paintable_get_icon_name     (GtkIconPaintable  *self);
+GDK_AVAILABLE_IN_ALL
+gboolean              gtk_icon_paintable_is_symbolic       (GtkIconPaintable  *self);
 
 G_END_DECLS